/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.demo.pam;

import org.jvnet.libpam.PAM;
import org.jvnet.libpam.PAMException;
import org.jvnet.libpam.UnixUser;

import java.util.Set;

/**
 * @author vacoor
 */
public class Demo {
    public static void main(String[] args) throws PAMException {
        PAM sshd = new PAM("sshd");
        try {
            UnixUser user = sshd.authenticate("vacoor", "");
            String username = user.getUserName();
            Set<String> groups = user.getGroups();
            System.out.println(username);
            for (String group : groups) {
                System.out.println(group);
            }
            UnixUser.exists(username);
        } catch (PAMException e) {
            throw e;
        }
    }
}
